package com.siecom.tool;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.siecom.zhq.hostservice.R;


/**
 * Created by macair on 2017/2/14.
 */
public class MyToast {

    public static Toast mToast;
    public static TextView mToastTv;



    public static void show(Context context,String text,int duration){

//        if(mToast == null){
            mToast = new Toast(context);
            View view = LayoutInflater.from(context).inflate(R.layout.toast_layout,null);
            mToastTv = (TextView)view.findViewById(R.id.tv_toast_show);
            mToast.setView(view);
            mToast.setGravity(Gravity.CENTER, 0, 20);
            mToast.setDuration(duration);
//        }
        mToastTv.setText(text);
        mToast.show();
    }

    public static void show(Context context,int resId,int duration){
        show(context,context.getString(resId),duration);
    }

}
